package com.faintlight.task;

import com.faintlight.service.CapsuleService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * 时光胶囊解锁任务
 */
@Component
@RequiredArgsConstructor
@Slf4j
public class CapsuleUnlockTask {

    private final CapsuleService capsuleService;

    @Scheduled(cron = "0 0 * * * ?")
    public void processUnlockTasks() {
        log.info("⏰ 开始执行每日胶囊解锁任务...");
        try {
            capsuleService.processUnlockTasks();
            log.info("✅ 时光胶囊解锁任务执行完成");
        } catch (Exception e) {
            log.error("❌ 时光胶囊解锁任务失败", e);
        }
    }
}
